import React, { Fragment } from 'react';
import { connect } from 'dva';
import BasePage from './BasePage'
import CurrentLocation from '../components/currentLocation'
import breadArr from '../constant/breadArr'
import style from '../assets/less/applicationProcessLess.less'
import { Timeline, Steps, Button } from 'antd';
import { ClockCircleOutlined, FormOutlined, CheckOutlined } from '@ant-design/icons';
import VeritificationProcess from '../components/veritificationProcess';
const { Step } = Steps;

class ApplicationProcessPage extends React.Component {
    constructor(props) {
        super(props),
            this.state = {
                refresh: true,
            }
    }

    refreshPage = () => {
        switch (this.props.verification.phase) {
            case 1:
                if (this.props.verification.examination != -1) {
                    this.props.dispatch({
                        type: "application/getTechnologyVerificationMechanismByTechnologyId",
                        data: {
                            verificationApplicationId: this.props.verification.technologyId
                        }
                    })

                    this.props.dispatch({
                        type: "application/getVerificationPhaseByTechnologyId",
                        data: {
                            id: this.props.verification.technologyId
                        }
                    })
                }
                break;
            case 2:
                this.props.dispatch({
                    type: "application/getTechnologyVerificationMechanismByTechnologyId",
                    data: {
                        verificationApplicationId: this.props.verification.technologyId
                    }
                })

                this.props.dispatch({
                    type: "application/getVerificationPhaseByTechnologyId",
                    data: {
                        id: this.props.verification.technologyId
                    }
                })
                break;
            case 3:
                this.props.dispatch({
                    type: "application/getVerificationAgreement",
                    data: { verificationApplicationId: this.props.verification.technologyId }
                })
                break;
            case 4:
                this.props.dispatch({
                    type: "application/getTestMechanismInformation",
                    data: { verificationApplicationId: this.props.verification.technologyId }
                })
                break;
            case 5:
                this.props.dispatch({
                    type: "application/getVerificationMechanismInformation",
                    data: { verificationApplicationId: this.props.verification.technologyId }
                })
                break;
            case 6:
                this.props.dispatch({
                    type: "application/getVerificationMechanismInformation",
                    data: { verificationApplicationId: this.props.verification.technologyId }
                })
                break;
            case 7:
                this.props.dispatch({
                    type: "application/getFinishedInformation",
                    data: { verificationApplicationId: this.props.verification.technologyId }
                })
                break;
        }
    }

    render() {
        return (
            <BasePage>
                <CurrentLocation breadArr={breadArr.ApplicationPage}></CurrentLocation>
                <div id={style.content}
                    onDoubleClick={this.refreshPage}
                >
                    <Steps
                        current={this.props.verification.phase - 1}
                        size='small'
                    >
                        <Step title="资格审查" />
                        <Step title="验证审查" />
                        <Step title="签订验证协议" />
                        <Step title="测试数据" />
                        <Step title="验证" />
                        <Step title="审查验证报告" />
                        <Step title="完成验证" />
                    </Steps>
                    <div id={style.verificationPhase}>
                        <VeritificationProcess></VeritificationProcess>
                    </div>
                </div>
            </BasePage>
        )
    }
}

const mapStateToProps = state => {
    let verification = state.application.verification
    return {
        verification
    }
}

export default connect(mapStateToProps)(ApplicationProcessPage)